package cn.silver.module.web.runner;

import cn.silver.module.authority.service.ISysClientService;
import cn.silver.module.authority.service.ISysTenantService;
import cn.silver.module.configuration.service.ISysDictService;
import cn.silver.module.configuration.service.ISysParamService;
import cn.silver.module.message.service.IMsgNoticeService;
import cn.silver.module.system.service.ISysUserRoleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhouxiaobo
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SilverApplicationRunner implements ApplicationRunner {
    private final ISysDictService dictService;
    private final ISysUserRoleService urService;
    private final ISysParamService paramService;
    private final ISysTenantService tenantService;
    private final ISysClientService clientService;
    private final IMsgNoticeService noticeService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始初始化客户端信息");
        List<String> result = this.clientService.init();
        log.info("客户端信息初始化完成, 已初始化客户端：{}", String.join(",", result));
        log.info("开始初始化租户信息");
        this.tenantService.init();
        log.info("租户信息初始化完成，已创建默认租户");
        log.info("开始初始化用户权限信息");
        this.urService.init();
        log.info("用户权限信息初始化完成，已创建超级管理员用户并授权");
        log.info("开始初始化系统配置信息");
        this.paramService.init();
        log.info("系统配置初始化完成");
        log.info("开始初始化数据字典");
        this.dictService.init();
        log.info("数据字典初始化完成");
//        this.noticeService.init();
    }
}
